---
title: Slider
description: An input where the user selects a value from within a given range.
component: true
links:
  doc: https://www.radix-ui.com/docs/primitives/components/slider
  api: https://www.radix-ui.com/docs/primitives/components/slider#api-reference
---

<ComponentPreview 
   name="slider-demo" 
   description="A slider component." 
   styleSwitch={true}
   button="copy"
   dots={false}
/>

## Installation

<Tabs defaultValue="cli">

<TabsList>
  <TabsTrigger value="cli">CLI</TabsTrigger>
  <TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>
<TabsContent value="cli">

```bash
npx nyxb@latest add slider
```

</TabsContent>

<TabsContent value="manual">

<Steps>

<Step>Install the following dependencies:</Step>

```bash
 @radix-ui/react-slider
```

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource name="slider" />

<Step>Update the import paths to match your project setup.</Step>

</Steps>

</TabsContent>

</Tabs>

## Usage

```tsx
import { Slider } from "~/components/ui/slider"
```

```tsx
<Slider defaultValue={[33]} max={100} step={1} />
```


## Examples

### Default

<ComponentPreview 
   name="slider-demo" 
   styleSwitch={true}
   button="copy"
   dots={false}
/>

### Disabled

<ComponentPreview 
   name="slider-disabled"
   styleSwitch={true}
   button="copy"
   dots={false}
/>

### Inverted

<ComponentPreview 
   name="slider-inverted" 
   styleSwitch={true}
   button="copy"
   dots={false}
/>

### Vertical

<ComponentPreview 
   name="slider-vertical" 
   styleSwitch={true}
   button="copy"
   dots={false}
/>

### Range

<ComponentPreview 
   name="slider-range" 
   styleSwitch={true}
   button="copy"
   dots={false}
/>

### Tick Marks

Use the `showSteps` prop to define tick marks' style.
NOTE: The tick marks' positions are not 100% accurate!

#### Half Tick Marks

<ComponentPreview 
   name="slider-tick-marks-half" 
   styleSwitch={true}
   button="copy"
   dots={false}
/>

#### Full Tick Marks

<ComponentPreview 
   name="slider-tick-marks-full" 
   styleSwitch={true}
   button="copy"
   dots={false}
/>

### Format Label

Use the `formatLabel` prop to define how the value is shown on popover.

<ComponentPreview 
   name="slider-format-label" 
   styleSwitch={true}
   button="copy"
   dots={false}
/>

### Format Label Side

Use the `formatLabelSide` prop to indicate where the popover will appear.

<ComponentPreview 
   name="slider-format-label-side" 
   styleSwitch={true}
   button="copy"
   dots={false}
/>
